-- @owner:songfei_st
-- @date:2024-8-2
-- @testpoint:1.嵌套数组类型，函数中使用，部分用例合理报错          


--prestep1:切换A库;expect:执行成功
@conn PrimaryDbAmode;

--step1:创建表;expect:成功
create table t_PLArray_Case0024(id int);

--step2:创建函数，返回值为嵌套数组;expect:失败，table of index type is not supported as function return type. at or near ";"
create or replace function f_PLArray_Case0024() returns int[][] as
$$
declare
   type typ_PLArray_1 is varray(3) of int;
   type typ_PLArray_2 is varray(4) of typ_PLArray_1;
   nstarr typ_PLArray_2;
begin
   nstarr(2)(1):=100;
   insert into t_PLArray_Case0024(id) values (nstarr(2)(1));
   return nstarr;
end
$$ language plpgsql;
/

--step3:创建函数，返回值不为嵌套数组;expect:成功
create or replace function f_PLArray_Case0024() returns int as
$$
declare
   type typ_PLArray_1 is varray(3) of int;
   type typ_PLArray_2 is varray(4) of typ_PLArray_1;
   nstarr typ_PLArray_2;
begin
   nstarr(2)(1):=100;
   insert into t_PLArray_Case0024(id) values (nstarr(2)(1));
   return 1;
end
$$ language plpgsql;
/

--step4:调用函数;expect:成功
call f_PLArray_Case0024();

--step5:查询数据;expect:成功,100
select * from t_PLArray_Case0024;

--清理环境;expect:成功(2 rows)
drop function f_PLArray_Case0024;
drop table t_PLArray_Case0024;
